<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html; charset=utf-8"/>
<title>Network</title>
<link href="index.css"rel="stylesheet"type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>深圳市飞通宽带有限公司</title>
</head>
<body class="bodystyle"  >
<script language="javascript" type="text/javascript">

var xmlhttp;

function loadXMLDoc(url,cfunc)
{  
   	if(window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
  		//针对某些特定的浏览器进行修正
  		if(xmlhttp.overrideMimeType){
   			xmlhttp.overrideMimeType("text/xml");
  		}
	}else if(window.ActiveXObject){
  		//针对ie5，ie5.5，ie6
  		var activexName=["MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
  		for(var i=0;i<activexName.length;i++){
   			try{
    			xmlhttp=new ActiveXObject(activexName[i]);
    			break;
   			}catch (e) {}
  		}
	}
	//确认xmlhttp对象创建成功
	if(!xmlhttp){
		alert("xmlhttprequest 创建失败！");
	}else{

	}
	
	xmlhttp.onreadystatechange=cfunc;
	xmlhttp.open("GET",url,true);
	xmlhttp.send();
}

window.onload = function()
{
	get_ip_info ();
}

function get_ip_info ()
{
	var parm = "/get_network_settings.cgi?";
	parm += "&t=" + Math.random();
	loadXMLDoc(parm,function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var ret = xmlhttp.responseText;
			var items = ret.split(",");
			document.getElementById("dhcp").value = items[0];
			document.getElementById("static_ip").value = items[1];
			document.getElementById("mask").value = items[2];
			document.getElementById("gateway_ip").value = items[3];
			get_snmp_info();
		}
	}
	);
}

function get_snmp_info()
{
	var parm = "/get_snmp_settings.cgi?";
	parm += "&t=" + Math.random();
	loadXMLDoc(parm,function()
	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var ret = xmlhttp.responseText;
			var items = ret.split(",");
			document.getElementById("trap_status1").value = items[0];
			document.getElementById("trap_status2").value = items[1];
			document.getElementById("trap_status3").value = items[2];
			document.getElementById("trap_status4").value = items[3];
			document.getElementById("trap_IP1").value = items[4];
			document.getElementById("trap_IP2").value = items[5];
			document.getElementById("trap_IP3").value = items[6];
			document.getElementById("trap_IP4").value = items[7];
			document.getElementById("trap_comm1").value = items[8];
			document.getElementById("trap_comm2").value = items[9];
			document.getElementById("trap_comm3").value = items[10];
			document.getElementById("trap_comm4").value = items[11];
			response.expires=0;
		}
	}
	);	
}

function isNumber(n) {  
    return !isNaN(parseFloat(n)) && isFinite(n);  
}  

function checkIpAddr(ipaddr)
{
   if(ipaddr == "")
   {
     return false;
   }

   var ss = ipaddr.split(".");

   if(ss.length != 4)
   {
      return false;
   }

   var i=0;
   for(i=0;i<ss.length;i++)
   {
      if ( !isNumber(ss[i]) || parseInt(ss[i]) < 0 || parseInt(ss[i])>255)
      {
        return false;
      }
   }

  return true;

}

/*****************************************************************
*函数名称  ：changePassword
*功能描述     修改密码
*输入参数：无
*输出参数：
*返回值：   无
*2016/02/08  wangkang
*******************************************************************
*/

function  networkSetting()
{
	var dhcp=document.getElementById("dhcp").value;
	//alert(dhcp);
	var sip=document.getElementById("static_ip").value;
	//alert(sip);
	var mask=document.getElementById("mask").value;
	//alert(mask);
	var gip=document.getElementById("gateway_ip").value;
	//alert(gip);
	

	if ( true != checkIpAddr ( sip ) )
	{
		alert ( "IP Address Error!" );
		return false;
	}

	if ( true != checkIpAddr ( mask ) )
	{
		alert ( "IP Mask Error!" );
		return false;
	}

	if ( true != checkIpAddr ( gip ) )
	{
		alert ( "Gateway Address Error!" );
		return false;
	}
	
	var parm = "/network_settings.cgi?";
	parm+="&dhcp="+dhcp;
	parm+="&ip="+sip;
	parm+="&mask="+mask;
	parm+="&gw="+gip;
	parm+="&t=";
	parm+=Math.random();
	
	loadXMLDoc(parm,function()//不能写成led0=0，因为遇到=号就代表结束
  	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var ret = xmlhttp.responseText;
			if ( ret == "0" )
			{
				alert ( "Setting Successful!\r\n" );
			}
			else
			{
				alert ( "Setting Failed!\r\n" );	
			}
		}
   }
   );
}
/*****************************************************************
*函数名称  ：restoreDefaule
*功能描述     数据重置
*输入参数：无
*输出参数：
*返回值：   无
*2016/02/08  wangkang
*******************************************************************
*/
function restoreDefaule()
{
	//alert("restoreDefaule");
	document.getElementById("dhcp").value=0;
	//alert(dhcp);
	document.getElementById("static_ip").value="192.168.0.8";
	document.getElementById("mask").value="255.255.255.0";
	document.getElementById("gateway_ip").value="192.168.0.1";
	//alert("emd");
}
/*****************************************************************
*函数名称  ：rebootMachine
*功能描述     重启路由器
*输入参数：无
*输出参数：
*返回值：   无
*2016/02/08  wangkang
*******************************************************************
*/
function rebootMachine()
{
	alert("reboot");
}
/*****************************************************************
*函数名称  ：snmpSetting
*功能描述     snmp设置
*输入参数：无
*输出参数：
*返回值：   无
*2016/02/08  wangkang
*******************************************************************
*/
function  snmpSetting()
{
	var trap_status1=document.getElementById("trap_status1").value;
	var trap_status2=document.getElementById("trap_status2").value;
	var trap_status3=document.getElementById("trap_status3").value;
	var trap_status4=document.getElementById("trap_status4").value;
	
	var trap_ip1 = document.getElementById("trap_IP1").value;
	var trap_ip2 = document.getElementById("trap_IP2").value;
	var trap_ip3 = document.getElementById("trap_IP3").value;
	var trap_ip4 = document.getElementById("trap_IP4").value;
	
	if ( true != checkIpAddr ( trap_ip1 ) || 
		 true != checkIpAddr ( trap_ip2 ) || 
		 true != checkIpAddr ( trap_ip3 ) || 
		 true != checkIpAddr ( trap_ip4 ) 
		)
	{
		alert ( "IP Address Error!" );
		return ;			 
	}
	
	var trap_commu1 = document.getElementById("trap_comm1").value;
	var trap_commu2 = document.getElementById("trap_comm2").value;
	var trap_commu3 = document.getElementById("trap_comm3").value;
	var trap_commu4 = document.getElementById("trap_comm4").value;

	var parm = "/snmp_settings.cgi?";
	parm+="&status1="+trap_status1;
	parm+="&status2="+trap_status2;
	parm+="&status3="+trap_status3;
	parm+="&status4="+trap_status4;
	parm+="&ip1=" + trap_ip1;
	parm+="&ip2=" + trap_ip2;
	parm+="&ip3=" + trap_ip3;
	parm+="&ip4=" + trap_ip4;
	parm+="&commu1=" + trap_commu1;
	parm+="&commu2=" + trap_commu2;
	parm+="&commu3=" + trap_commu3;
	parm+="&commu4=" + trap_commu4;
	parm+="&t=";
	parm+=Math.random();
	
	loadXMLDoc(parm,function()
  	{
		if (xmlhttp.readyState==4 && xmlhttp.status==200)
		{
			var ret = xmlhttp.responseText;
			if ( ret == "0" )
			{
				alert ( "Setting Successful!\r\n" );
			}
			else
			{
				alert ( "Setting Failed!\r\n" );	
			}
		}
   });
}

</script>
<div style="background-color:#FFF;" >
  <tr align="left">
    <td colspan="2"bgcolor="#FFFFFF"><table border="0"cellpadding="0"cellspacing="0">
        <tr>
          <td align="center" rowspan="2" width="100"><img src="images/Logo.jpg"alt=""width="67"height="62"/></td>
          <td rowspan="2" width="200"><img src="images/photon.gif" alt=""width="95"height="24"/></td>
          <td colspan="2" width="700"class="txtstyle_2"><blockquote>
              <p>TECHNOLOGY CORPORATION</p>
            </blockquote></td>
        </tr>
        <tr>
          <td align="right"class="txtstyle_1">A Lead of HFC Network Equipments Manufacturer</td>
        </tr>
      </table></td>
  </tr>
  <div class="menu">
    <ul class="ul1">
      <li class="li1"><a href="device.html">Device</a></li>
      <li class="current"><a href="network.html">Network</a></li>
      <li class="li1"><a href="security.html">Security</a></li>
    </ul>
  </div>
</div>
<td colspan="2"bgcolor="#FFFFFF"><table width="1000" border="0" align="center"cellpadding="0"cellspacing="0">
    <form name="network"method="POST" action="/network_settings.cgi">
      <tr>
        <td colspan="2"bgcolor="#EDEFEF"><div class="subitem_1">Network Settings</div></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">DHCP Client</div></td>
        <td bgcolor="#EDEFEF"><select  id="dhcp"name="dhcp"class="item_2"style="WIDTH: 80px">
            <option value="0" selected>Disable</option>
            <option value="1">Enable</option>
          </select></td>
      </tr>
      <tr>
        <td width="260"bgcolor="#EDEFEF"><div class="item_1">Static IP Address</div></td>
        <td width="530"bgcolor="#EDEFEF"><input id="static_ip" name="staticip"type="text"class="item_2"style="WIDTH: 140px"maxlength="15"autocomplete="off"/>
          <span id="static_ip_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Static Subnet Mask</div></td>
        <td bgcolor="#EDEFEF"><input name="maskip"id="mask"type="text"class="item_2"style="WIDTH: 140px"maxlength="15"autocomplete="off"/>
          <span id="mask_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Static Default Gateway</div></td>
        <td bgcolor="#EDEFEF"><input id="gateway_ip"name="gatewayip"type="text"class="item_2"style="WIDTH: 140px"maxlength="15"autocomplete="off"/>
          <span id="gateway_ip_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td colspan="2"bgcolor="#EDEFEF">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="2"align="center"bgcolor="#EDEFEF"><input name="Apply"type="button"class="item_2"style="WIDTH: 60px; HEIGHT: 24px;"onclick="networkSetting()"value="Apply"/>
          <input name="Cancel"type="reset"class="item_2"style="WIDTH: 60px; HEIGHT: 24px;"value="Cancel"/>
          <input name="restore"type="button"class="item_2"style="WIDTH: 122px; HEIGHT: 24px;"onclick="restoreDefaule()"value="Restore default"/>
          <input name="reboot"type="submit"class="item_2"style="WIDTH: 80px; HEIGHT: 24px;" onclick="rebootMachine()"value="Reboot"/></td>
      </tr>
    </form>
    <form name="network_0"method="POST"onsubmit="return chkForm(1);">
      <tr>
        <td colspan="2"bgcolor="#EDEFEF"><div class="subitem_1"><strong>Snmp Settings</strong></div></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Status 1</div></td>
        <td bgcolor="#EDEFEF"><select id="trap_status1"name="trap_status1"class="item_2"style="WIDTH: 80px"autocomplete="off">
            <option value="0" selected>Disable</option>
            <option value="1">Enable</option>
          </select></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Status 2</div></td>
        <td bgcolor="#EDEFEF"><select id="trap_status2"name="trap_status2"class="item_2"style="WIDTH: 80px"autocomplete="off">
            <option value="0" selected>Disable</option>
            <option value="1">Enable</option>
          </select></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Status 3</div></td>
        <td bgcolor="#EDEFEF"><select id="trap_status3"name="trap_status3"class="item_2"style="WIDTH: 80px"autocomplete="off">
            <option value="0" selected>Disable</option>
            <option value="1">Enable</option>
          </select></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Status 4</div></td>
        <td bgcolor="#EDEFEF"><select id="trap_status4"name="trap_status4"class="item_2"style="WIDTH: 80px"autocomplete="off">
            <option value="0" selected>Disable</option>
            <option value="1">Enable</option>
          </select></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap IP 1</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_IP1" id="trap_IP1"type="text"class="item_2"style="WIDTH: 140px"value=""maxlength="15"autocomplete="off"/>
          <span id="trap_IP1_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap IP 2</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_IP2"id="trap_IP2"type="text"class="item_2"style="width: 140px"value=""maxlength="15"autocomplete="off"/>
          <span id="trap_IP2_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap IP 3</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_IP3" id="trap_IP3"type="text"class="item_2"style="width: 140px"value=""maxlength="15"autocomplete="off"/>
          <span id="trap_IP3_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap IP 4</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_IP4"id="trap_IP4"type="text"class="item_2"style="width: 140px"value=""maxlength="15"autocomplete="off"/>
          <span id="trap_IP4_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Community 1</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_comm1"id="trap_comm1"type="text"class="item_2"style="width: 140px"value=""maxlength="10"autocomplete="off"/>
          <span id="trap_comm1_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Community 2</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_comm2"id="trap_comm2"type="text"class="item_2"style="width: 140px"value=""maxlength="10"autocomplete="off"/>
          <span id="trap_comm2_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Community 3</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_comm3"id="trap_comm3"type="text"class="item_2"style="width: 140px"value=""maxlength="10"autocomplete="off"/>
          <span id="trap_comm3_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td bgcolor="#EDEFEF"><div class="item_1">Trap Community 4</div></td>
        <td bgcolor="#EDEFEF"><input name="trap_comm4"id="trap_comm4"type="text"class="item_2"style="width: 140px"value=""maxlength="10"autocomplete="off"/>
          <span id="trap_comm4_msg"class="errMsg0"></span></td>
      </tr>
      <tr>
        <td colspan="2"align="center"bgcolor="#EDEFEF"><input name="Apply"type="button"class="item_2"style="WIDTH: 60px; HEIGHT: 24px;"onclick="snmpSetting()"value="Apply"/>
          <input name="Cancel"type="reset"class="item_2"style="WIDTH: 60px; HEIGHT: 24px;"value="Cancel"/></td>
      </tr>
    </form>
    <tr>
      <td colspan="2"bgcolor="#EDEFEF">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2"bgcolor="#C0C0C0">&nbsp;</td>
    </tr>
  </table>
</body>
</html>